<%-- 
    Document   : finance_content
    Created on : Oct 30, 2010, 12:30:02 PM
    Author     : M Bilal
--%>

<%@page import="wap.rockvilletech.portal.DBProc"%>
<%@ page import="java.io.*,java.sql.*,java.net.*"%>
<%@ page import="org.apache.log4j.Logger"%>

<% final Logger log = Logger.getLogger("JSP.finance_content"); %>

<%@ include file="../includes/header.jspf" %>

<div style="padding: 5px 0px 0px 0px;">
    <div class="div_navigation" id="div_navigation">
        <a href="<%=context_Path%>" class="LinkIndex">Home</a>&nbsp;&gt;
        <a href="<%=context_Path%>/finance/finance.jsp" class="LinkIndex">Finance</a>&nbsp;&gt;
        <span class="navigation_Leaf">Finance News</span>
    </div>
</div>

<%
try {
    thisPage = "Finance-News";
    DBProc db=DBProc.getInstance();

    int image_width = (int) (wurfl_screenWidth * 0.25);
    String feedId = request.getParameter("feed") != null ? request.getParameter("feed") : "";
    String str_feed_title=(request.getParameter("ftitle") != null && !request.getParameter("ftitle").isEmpty())?request.getParameter("ftitle"):"";
    String strNewsDate="";
    //pagging variables
    int intBlockLength = 5, intRecordsToBeDisplayed = 0, intRecordsToBeFetched = 0, intCountTotal = 0, intPageID = 0, intLastPage = 0;
	String strPagingLinks = "", pid = "";
	boolean computePaging = false, isNext = true;
	pid = request.getParameter("pid") != null ? request.getParameter("pid") : "0";
        Vector vFeedNews = db.getNewsFeed(pid,feedId);
	intCountTotal = (Integer)vFeedNews.get(0);
        intRecordsToBeDisplayed = intRecordsToBeFetched = (Integer)vFeedNews.get(1);

	try {
		intLastPage = intCountTotal / intRecordsToBeDisplayed;
		intPageID = Integer.parseInt(pid);
		if (intPageID > intLastPage) {
        	intPageID = intLastPage;
        }
        if(intCountTotal == (int)(intRecordsToBeDisplayed*(intPageID+1)))
        	intLastPage--;
    } catch(NumberFormatException ex) {
    	log.warn("number format exception at content_category.jsp =" + ex.toString());
    }

    int totalPicsInChannel = vFeedNews.size()-2;
	if (totalPicsInChannel + 1 < intRecordsToBeFetched) {
		intRecordsToBeDisplayed -= (intRecordsToBeFetched - totalPicsInChannel);
		intRecordsToBeFetched = totalPicsInChannel;
        isNext = false;
	}

	computePaging = totalPicsInChannel > 0;
	String strThisPageName = "contentCategory.jsp";
	String strThisPageRequestUrl=wap.rockvilletech.util.RequestUrlHelper.getRequest_QueryString_CurrentPage(request, strThisPageName);

	if (totalPicsInChannel > 0) {
                String ititle="",thumb="";
	%>
 <div>
         <table width="100%" align="left" cellpadding="0" cellspacing="0" style="text-align: left;font-weight: bold;">
                <tr>
                    <td style="background-image:url('../images/new/top_bar_02.jpg');background-repeat: repeat-x;height:26px;">
                        <b style="padding:0px 0px 0px 5px;"><%=str_feed_title%></b>
                    </td>
                 </tr>
            </table>
</div>
                    <div style="clear: both;"></div>

<div id="newsBlock" class="newsBlock" align="center">
    <div id="newBloackWidthMainter" class="newBloackWidthMainter">

<%
    try {
            int intNewsId = 0;

		for (int idx=2; vFeedNews.size()>idx; idx++) {
			try {
				String[] arrTemp =(String[]) vFeedNews.get(idx);
				intNewsId =Integer.parseInt(arrTemp[0]);
				ititle = arrTemp[1];
				thumb = arrTemp[2];
				strNewsDate = arrTemp[3];

			try {
                                ititle = wap.rockvilletech.util.StringUtils.toUnicode(ititle);
                                ititle=java.net.URLDecoder.decode(ititle,"UTF-8");
                                ititle=ititle.replaceAll("%20"," ");
				} catch(Exception exDecode){}

%>
        		<div id="newsItem" class="newsItem">
            		<a class="newsFeed" href="content.jsp?page=<%=thisPage%>&feed=<%=feedId%>&newsitemid=<%=intNewsId%>&pid=<%=pid%>&ftitle=<%=str_feed_title%>">
<%
                    if (thumb != null && thumb.length() > 1) {
                    	thumb = java.net.URLEncoder.encode(thumb, "UTF-8");
%>
                <img src="<%=context_Path%>/imgsrv?img=<%=thumb%>&s=0&repo=http&w=<%=image_width%>" alt="" style="<%=css_Img%>" align="left" />
<%
                    }
%>
                	<b><%=ititle%></b><br/><%=strNewsDate%>
            		</a>
		        </div>
        		<div class="clearFloat blueUnderline"></div>
<%
            } catch (Exception e) {
            	log.error("content_category.jsp",e);
            }
        } // end - for loop for items

if (computePaging) {
			// Call the method which will generate Page links
			wap.rockvilletech.util.Paging.computePaging(request,
				"content_category.jsp?",
				intRecordsToBeFetched, intRecordsToBeDisplayed,
				intCountTotal, intBlockLength, intLastPage, intPageID,
				isNext);

			// Get the generated Summary and links
			strPagingLinks = wap.rockvilletech.util.Paging.getPagingLinks();
			//--out.println(strPagingLinks);
		}


    } catch (Exception e) {
    	log.error("content_category.jsp Page", e);
%>
            Unable to get news headlines.<br />
            <a href="<%=strThisPageRequestUrl%>">Click here to refresh the page</a>
<%
    }
%>
    </div>

    <div class="divStepFoot"><%=strPagingLinks%></div>
</div>

<%
} // RSS Data bean check
else {
%>
    <div id="newsBlock" class="newsBlock">
        Unable to get news headlines.<br /><a href="<%=strThisPageRequestUrl%>">Click here to refresh the page</a>
    </div>
<%
}


}
catch(Exception ex) {
    log.error(ex);
}
%>
<div style="padding-top:5px;text-decoration: underline;">
            <jsp:include page="../banner.jsp">
                <jsp:param name="w" value="<%=width%>"/>
            </jsp:include>
</div>

<%@ include file="../includes/footer.jspf" %>


<%
wpb.LogVisit(strIP, thisPage, strGsm,strApn,strBrand,strModel, app,request.getQueryString());
%>